<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script src="js/jquery.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      header {
        width: 100%;
        display: flex;
        align-items: center;
      }
      .box1 {
        width: 100%;
        height: 100%;
        /* background-repeat: no-repeat; */
        margin: 0 auto;
        background-image: url(img/10062.jpg);
      }
      .box {
        width: 700px;
        height: 400px;
        margin: 0 auto;
        display: flex;
      }
      .left {
        width: 400px;
        position: relative;
      }
      .left .hh {
        margin: 20px 0 30px 40px;

        cursor: pointer;
      }
      .left .hhh {
        position: absolute;
        top: 0;
        left: 260px;
      }
      .right {
        width: 152px;
        text-align: center;
        padding-left: 87px;
        margin-top: 20px;
      }
      .left .hhh {
        margin: 20px 0 30px 40px;
        cursor: pointer;
      }
      .left input {
        width: 250px;
        height: 35px;
        outline: none;
        border: none;
        border-radius: 5px;
        margin: 10px;
        margin-left: 30px;
        border: 1px solid #cecece;
      }
      .left .btn {
        width: 250px;
        height: 35px;
        text-align: center;
        margin-left: 32px;
        outline: none;
        border: none;
        border-radius: 4px;
        background-image: linear-gradient(134deg, #00d4e3 0, #00cad8 100%);
        cursor: pointer;
      }
      .left .input2 {
        width: 10px;
        height: 10px;
      }
      .left p span {
        font-size: 12px;
      }
      .left .p1 {
        margin: 40px 0 0 30px;
        font-size: 12px;
        cursor: pointer;
        float: left;
      }
      .left .p2 {
        display: block;
        margin: 35px 0 0 110px;
      }
      #box2 {
        position: absolute;
        top: 70px;
        left: 60px;
        display: none;
      }
      #box2 .btn1 {
        width: 250px;
        height: 35px;
        text-align: center;
        margin-left: 32px;
        outline: none;
        border: none;
        border-radius: 4px;
        background-image: linear-gradient(134deg, #00d4e3 0, #00cad8 100%);
        cursor: pointer;
      }
      .q1 {
        position: absolute;
        display: block;
        width: 204px;
        height: 28px;
        color: rgb(128, 33, 33);
        font-size: 14px;
        top: 93px;
        left: 286px;
      }
      .jpg {
        width: 200px;
        height: 200px;
        margin-top: 15px;
      }
    </style>
    <div class="box1">
      <div class="box">
        <div class="left">
          <h3 class="hh">注册</h3>
          <h3 class="hhh">登录</h3>
          <div id="box1">
            <input type="text" placeholder="手机号/邮件地址/账号名" /><br />
            <input type="password" placeholder="密码" /><br />
            <button class="btn">注册</button><span class="q1"></span>
            <p>
              <input type="checkbox" class="input2" /><span
                >已阅读并同意《去哪儿用户服务协议》、《隐私政策》</span
              >
            </p>
            <p class="p1">其他登录方式</p>
          </div>
          <div id="box2">
            <input type="text" placeholder="请输入用户名" /><br />
            <input type="password" placeholder="请输入密码" /><br />
            <button class="btn1">登录</button><span class="q2"></span>
            <p>
              <input type="checkbox" class="input2" /><span
                >已阅读并同意《去哪儿用户服务协议》、《隐私政策》</span
              >
            </p>
            <p class="p1">其他登录方式</p>
          </div>
        </div>
        <div class="right">
          <h3>手机扫码安全登录</h3>
          <img src="img/10058.jpg" alt="" class="jpg" />
        </div>
      </div>
    </div>
    <script>
      var oDiv = document.querySelector(".hh");
      var aDiv = document.querySelector(".hhh");
      oDiv.onclick = function () {
        box1.style.display = "block";
        box2.style.display = "none";
      };
      aDiv.onclick = function () {
        box2.style.display = "block";
        box1.style.display = "none";
      };

      var Input = document.querySelectorAll("input");
      var Q = document.querySelector(".q1");
      var btn = document.querySelector(".btn");
      var btTn = document.querySelector(".btn1");

      btn.onclick = function () {
        $.get("http://jx.xuzhixiang.top/ap/api/reg.php", {
          username: Input[0].value,
          password: Input[1].value,
        }).then((res) => {
          console.log(res);
          console.log(res.msg);
          let a = res.msg;
          Q.innerText = a;
          console.log(Q.value);
        });
      };
      btTn.onclick = function () {
        $.get("http://jx.xuzhixiang.top/ap/api/login.php", {
          username: Input[3].value,
          password: Input[4].value,
        }).then((res) => {
          console.log(res);
          if (res.code == 1) {
            function jump() {
              location.href = "index.html";
            }
            jump();
          } else {
            alert("请检查用户名或者密码");
          }
        });
      };
    </script>
  </body>
</html>
